package com.mc.web.controller.fil;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mc.common.annotation.Log;
import com.mc.common.core.controller.BaseController;
import com.mc.common.core.domain.AjaxResult;
import com.mc.common.enums.BusinessType;
import com.mc.fil.domain.FilManure;
import com.mc.fil.service.IFilManureService;
import com.mc.common.utils.poi.ExcelUtil;
import com.mc.common.core.page.TableDataInfo;

/**
 * 底肥信息 Controller
 *
 * @author mc
 * @date 2021-04-15
 */
@RestController
@RequestMapping("/fil/manure")
public class FilManureController extends BaseController
{
    @Autowired
    private IFilManureService filManureService;

    /**
     * 查询底肥信息 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:manure:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilManure filManure)
    {
        startPage();
        List<FilManure> list = filManureService.selectFilManureList(filManure);
        return getDataTable(list);
    }

    /**
     * 导出底肥信息 列表
     */
    @PreAuthorize("@ss.hasPermi('fil:manure:export')")
    @Log(title = "底肥信息 ", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FilManure filManure)
    {
        List<FilManure> list = filManureService.selectFilManureList(filManure);
        ExcelUtil<FilManure> util = new ExcelUtil<FilManure>(FilManure.class);
        return util.exportExcel(list, "manure");
    }

    /**
     * 获取底肥信息 详细信息
     */
    @PreAuthorize("@ss.hasPermi('fil:manure:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(filManureService.selectFilManureById(id));
    }

    /**
     * 新增底肥信息
     */
    @PreAuthorize("@ss.hasPermi('fil:manure:add')")
    @Log(title = "底肥信息 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilManure filManure)
    {
        return toAjax(filManureService.insertFilManure(filManure));
    }
}
